package chapter02;

public class Test06_package {
    public static void main(String[] args) {
        Teacher t = new Teacher();
        t.setAge(-1);
        System.out.println(t.getAge());
        t.setName("张三");
        System.out.println(t.getName());
    }
}
class Teacher{
    private int age;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    private String name;
    public int getAge(){
        //this就是Python的self
        return this.age;
    }
    public void setAge(int age){
        if(age<0){
            System.out.println("您输入的年龄有误");
        }else{
            this.age = age;
        }
    }
}
